#!/bin/bash

# 更新GET helper
sed -i '/export const get = /,/^}$/c\
export const get = <T = any>(url: string, config?: AxiosRequestConfig): Promise<ApiResponse<T>> => {\
  return client.get(url, config).then(res => res.data)\
}' client.ts

# 更新POST helper
sed -i '/export const post = /,/^}$/c\
export const post = <T = any>(\
  url: string,\
  data?: any,\
  config?: AxiosRequestConfig\
): Promise<ApiResponse<T>> => {\
  return client.post(url, data, config).then(res => res.data)\
}' client.ts

# 更新PUT helper
sed -i '/export const put = /,/^}$/c\
export const put = <T = any>(\
  url: string,\
  data?: any,\
  config?: AxiosRequestConfig\
): Promise<ApiResponse<T>> => {\
  return client.put(url, data, config).then(res => res.data)\
}' client.ts

# 更新DELETE helper  
sed -i '/export const del = /,/^}$/c\
export const del = <T = any>(url: string, config?: AxiosRequestConfig): Promise<ApiResponse<T>> => {\
  return client.delete(url, config).then(res => res.data)\
}' client.ts

echo "Helper functions updated to extract response.data"
